@extends('layouts.vote.unregister.vote')
@section('title')
    <h1 class="center" id="vote-title"></h1>
@endsection
@section('test')
    @endsection
@section('listContent')
    <div class="detailCon mt20 pb30">
        @if($data['type']=='3')
        <video  controls poster="/images/vote/unregister/demo2.jpeg">
            <source src="{{$data['src']}}" type="video/mp4">
            您的浏览器不能使用最新的视频播放方式呢
        </video>
        @elseif($data['type']=='2')
            <audio  controls>
                <source src="{{$data['src']}}" title="音频" type="video/mp4">
                您的浏览器不能使用最新的视频播放方式呢
            </audio>
        @elseif($data['type']=='1')
            <img src="{{$data['cover']}}" alt="">
        @endif
        <div class="ui-whitespace">
            <h2 class="mt20">{{ $data['name'] }}</h2>
            <p class="mt20">{{ $data['content'] }}</p>
            <div class="productionStates mt20">
                <div>
                    <p>{{$data['votes']}}票</p>
                    <p>票数</p>
                </div>
                <div>
                    <p>{{$data['rank']}}</p>
                    <p>排名</p>
                </div>
            </div>
            <a class="productionBtn mt20" onclick="vote('{{$data['vote_id']}}','{{$data['id']}}')" href="#">投票</a>
        </div>
    </div>
@endsection
@section('script')
    <script src="/js/vote/unregister/vote_detail.js"></script>
    <script>
        function vote($act_id,$item_id) {
            if (window.__uid == "") {
                var warring=layer.alert('请下载App投票', {icon: 2});
                layer.style(warring, {color:'#393D49'});
                return;
            }

            $.ajax({
                url: "{{env('LUA_SERVER')}}/api/vote/vote",
                data: {vote_id: $act_id, item_id: $item_id, uid: window.__uid},
                type: 'get',
                dataType: 'json',
                success: function (response) {
                    if (response.code == 200) {
                            layer.msg('投票成功！',{icon: 1}, function () {
                            window.location.reload();
                        });
                    } else {
                        var warring=layer.alert(response.message, {icon: 2});
                        layer.style(warring, {color:'#393D49'});
                    }
                },
                error: function () {
                }
            });
        }
    </script>
@endsection

